package com.dingwen.treasure.business.controller;

import com.cdn.treasure.annotation.SensitiveDecode;
import com.cdn.treasure.annotation.SensitiveEncode;
import com.dingwen.treasure.base.controller.BaseViewController;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.business.model.entity.SensitiveEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 加解密、脱敏 API
 *
 * @author dingwen
 * @date 2022/12/14
 */
@Api(tags = "加解密脱敏API")
@RestController
@Slf4j
@RequestMapping("sensitive")
public class SensitiveController implements BaseViewController {

    /**
     * 解密、脱敏
     *
     * @return result
     */
    @PostMapping("decode")
    @ApiOperation("解密脱敏")
    @SensitiveDecode(entity = SensitiveEntity.class)
    public Result<SensitiveEntity> decode(@RequestBody SensitiveEntity sensitive) {
        return success(sensitive);
    }

    /**
     * 加密、脱敏
     *
     * @param sensitive
     * @return sensitive
     */
    @PostMapping("encode")
    @ApiOperation("加密脱敏")
    @SensitiveEncode(entity = SensitiveEntity.class)
    public Result<SensitiveEntity> encode(@RequestBody SensitiveEntity sensitive) {
        return success(sensitive);
    }


}
